<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="css/eui.css">
    <style>
        body{
            margin: 0;
            background-image: url("../../../../vue/src/assets/a.jpg");
            background-size: cover;/*cover是专门用来设置全屏背景的*/
            text-align: center;
        }
        h1{
            font-size: 72px;
            color: rgb(232, 159, 81);
            margin-bottom: 0;
        }
        img{
            width: 100px;
        }
        h2{
            font-size: 32px;
            color: rgb(232,159,81);
            margin:0;
        }

    </style>
</head>
<body>
<div id="app">
    <h1>用户注册</h1>
    <img src="img/xyy.png" alt="">
    <h2>Sunset Red</h2>
    <el-card style="width: 580px;height: 370px;
    margin: 0 auto;background-color: rgba(255,255,255,0.3)" >
        <el-form style="width: 400px;margin: 30px auto" label-width="60px" @keydown.native.enter="login()">
            <el-form-item label="昵称">
                <el-input type="text" v-model="user.nick" placeholder="请输入昵称"></el-input>
            </el-form-item>
            <el-form-item label="用户名">
                <el-input type="text" v-model="user.username" placeholder="请输入用户名"></el-input>
            </el-form-item>
            <el-form-item label="密码">
                <el-input type="password" v-model="user.password" placeholder="请输入密码"></el-input>
            </el-form-item>
            <el-form-item label="手机号">
                <el-input type="text" v-model="user.phone" placeholder="请输入手机号"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button :plain="true" style="position: relative;right: 35px" type="primary" @click="reg()">注册</el-button>
            </el-form-item>
        </el-form>
    </el-card>
</div>
</body>
<!-- import Vue before Element -->
<script src="js/vue.js"></script>
<!-- import JavaScript -->
<script src="js/eui.js"></script>
<script src="js/axios.min.js"></script>
<script>
    let v = new Vue({
        el: '#app',
        data: function() {
            return {
                user:{
                    username:"",
                    nick:"",
                    password:"",
                    phone:""
                }
            }
        },
        methods:{
            reg(){
                axios.post("/reg",v.user).then(function (response){
                    if (response.data==1 || response.data == null){
                        location.href="/login.html";
                    }else {
                        v.$message.error("用户名已存在或者信息未输入")
                    }
                })
            }
        }
    })
</script>
</html>